{include file="admin/top.php" subject='orders'}
{include file="orders/top.php" subject='orders'}

<div id="content">

    <div id="boxquery">
    <form method="get">
         <input type="hidden" name="m" value="inventory" />
        <input type="hidden" name="s" value="orders.php" />
        <input type="submit" value="查询" class="fr" />
        <li>仓库:&nbsp; <select id="shopid" name="shopid"><option value="">全部</option>{shops}<option value="{$shops.id}" {if $shops.id==$smarty.get.shopid}selected{/if}>{$shops.title}</option>{/shops}</select></li>
        <li class="yui-skin-sam">出库时间:&nbsp; 
            <input id="sdate" name="sdate" type="text" size="12" value="{$smarty.get.sdate}" onfocus="lockinput(this)" />
            <input id="edate" name="edate" type="text" size="12" value="{$smarty.get.edate|default:$smarty.now|date_format:'%Y-%m-%d'}" onfocus="lockinput(this)" />
            <div id="calContainer" style="display:none; position:absolute;"></div>
        </li>
        <li><div style="line-height: 15px;float:left;">产品ID:&nbsp; </div><textarea id="product_id" name="product_id" style="resize:horizontal;float:left;height:30px;">{$smarty.get.product_id}</textarea>
        </li>
        <li>产品关键字:&nbsp; <input id="keywords" name="keywords" type="text" size="30" value="{$smarty.get.keywords}" /><!--  onclick="select()"
        onkeyup="context_menu_products(this, 'productid=[id],keywords=[title]')" onfocus="context_menu_products(this, 'productid=[id],keywords=[title]')" -->
        <input id="productid" name="productid" type="hidden" value="{$smarty.get.productid}" />
        </li>
        <li>数量:&nbsp; <input id="lnumber" name="lnumber" type="text" size="4" value="{$smarty.get.lnumber}"/>-<input id="hnumber" name="hnumber" type="text" size="4" value="{$smarty.get.hnumber}"/>
        </li>
       	<li>&nbsp;&nbsp;&nbsp;订单号:&nbsp; <input id="lotnumber" name="lotnumber" type="text" size="20"  value="{$smarty.get.lotnumber}" />
        <li>&nbsp;&nbsp;&nbsp;产品条码:&nbsp; <input id="barcode" name="barcode" type="text" size="15"  value="{$smarty.get.barcode}" />
        </li>
        <li>类型:&nbsp; <select id="type" name="type"><option value="">全部类型</option>{html_options options=$type selected=$smarty.get.type}</select></li>
        <li>状态:&nbsp; <select id="status" name="status"><option value="all" >全部</option><option value="0" {if !$smarty.get.status or "0"===$smarty.get.status}selected{/if}>未处理</option><option value="1" {if "1"===$smarty.get.status}selected{/if}>已出库</option><option value="-1" {if "-1"===$smarty.get.status}selected{/if}>未出库</option></select></li>
    </form>
    </div>
	<form action="{$site_admin}m=inventory&s=orders.php&uri=stockconfirm" method="post" onsubmit="return confirm('操作数据后不可恢复, 确定出库?')">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="lister">
      <tbody>
      <tr id="title">
        {if $smarty.get.status==='0' or $smarty.get.status==''}<td width="40"><input type="checkbox" class="checkall" ></td>{/if}
        <td width="40">序号</td>
        <td width="50">仓库</td>
        <td width="40">产品ID</td>
        <td>产品图</td>
        <td>产品名称</td>
        <td>规格</td>
        <td width="20">单位</td>
        <td align="center" width="50">出库数量</td>
        <td align="center" width="100">库存数(采购在途)</td>
        <td width="160">出库类型</td>
        <td>出库时间</td>
        <td width="80">出库状态</td>
        <td width="50">操作员</td>
        <td></td>
      </tr>
      {orders limit=20 pager=pager page=$segment.page order="id desc" shopid=$smarty.get.shopid productid=$smarty.get.productid product_id=$smarty.get.product_id keywords=$smarty.get.keywords sdate=$smarty.get.sdate edate=$smarty.get.edate counter=1 type=$smarty.get.type lnumber=$smarty.get.lnumber hnumber=$smarty.get.hnumber lotnumber=$smarty.get.lotnumber status=$smarty.get.status barcode=$smarty.get.barcode}
      <tr id="content">
        {if $smarty.get.status==='0' or $smarty.get.status==''}<td><input type="checkbox" value="{$orders.id}" class="checkitem" name="chk[]" {if $orders.number-$orders.stocks>0}disabled{/if}></td>{/if}
        <td>{$orders.id}</td>
        <td>{$orders.shop}</td>
        <td>{$orders.pid}</td>
        <td><img src="{$orders.product_pic}" width="50" height="50"/></td>
        <td>{$orders.product}</td>
        <td>{$orders.spec}</td>
        <td>{$orders.unit}&nbsp;</td>
        <td align="center"><b>{$orders.number+0}&nbsp;</b></td>
        <td align="center"{if $orders.number-$orders.stocks-$orders.purchases>0}style="color:red"{/if}>{$orders.stocks+0}({$orders.purchases+0})</td>
        <td>{$orders.type}{if $orders.lotnumber}({$orders.lotnumber}){/if}</td>
        <td>{$orders.thedate|date_format:'%Y-%m-%d<br>%H:%M:%S'}</td>
        <td>{if $orders.timestocked==0}{rights right='orders_stock'}{if $orders.number-$orders.stocks>0}库存不足{else}<a href="{$site_admin}m=inventory&s=orders.php&orders_id={$orders.id}&uri=stockconfirm"  onclick="return confirm('操作不可恢复, 确定出库?')">确认出库？</a>{/if}{/rights}
        {else}{if $orders.timestocked>0}已出库{else}未出库{/if}{/if}</td>
        <td>&nbsp;</td>
        <td align="right">
        {if $orders.timestocked==0}
        {rights right='orders_modify'}<a href="{$site_admin}m=inventory&s=orders.php&orders_id={$orders.id}&uri=modify&page={$segment.page}">编辑</a>{/rights}
        {elseif $orders.timestocked<0}
<!--          {rights right='orders_remove'}<a href="{$site_admin}m=inventory&s=orders.php&orders_id={$orders.id}&uri=remove" onclick="return confirm('删除数据不可恢复, 确定删除?')">删除</a>{/rights} -->
        {/if}
        <a href="{$site_admin}m=inventory&s=orders.php&orders_id={$orders.id}&uri=view&page={$segment.page}&status={$smarty.get.status}">查看</a>
        </td>
      </tr>
      {/orders}
      {if $pager->rows==0}
      <tr id="content">
        <td colspan="20">&nbsp;</td>
      </tr>
      {/if}
      </tbody>
      	{if $smarty.get.status==='0' or $smarty.get.status==''}<tfoot>
            <tr>
                <td colspan="15">
	                <input type="hidden" name="act" value="op" />
                    <input type="submit" value="批量出库" />
                </td>
            </tr>
        </tfoot>{/if}
    </table>
    </form>
    <div id="pager" class="mt10">
        {if $pager}<span class="fr"><strong>合计</strong>: 出库数量:{$orders.counter.number+0} </span> 共{$pager->rows}条记录 第{$pager->pagecurrent}/{$pager->pages}页 {/if} 		
        {if $pager->current > 1}<a href="{url s1=1}">首页</a>{/if}
        {if $pager->current > 1}<a href="{url s1=$pager->current-1}">上页</a>{/if}
        {if $pager->current < $pager->pages}<a href="{url s1=$pager->current+1}">下页</a>{/if}
        {if $pager->current < $pager->pages}<a href="{url s1=$pager->pages}">尾页</a>{/if}
	</div>
	<p>&nbsp;</p>
    {rights right='orders_create'}<ul id="addmenu"><li><a href="{$site_admin}m=inventory&s=orders.php&uri=create">添加一个新的产品出库</a></li></ul>{/rights}
    <form method="post" target="export_iframe" id="export_form" action=""><input type="hidden" value="export" name="act"/></form>
    <iframe src="" style="display:none;" id="export_iframe" name="export_iframe"></iframe>
    <div style="float:right" id="els_export">
            <a href="javascript:;" onclick="$('#export_form').submit();">导出EXCEL</a></div>
</div>
{include file="admin/bottom.php"}
</body>
</html>
